#include <bits/stdc++.h>

using namespace std;

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T, n, m, L, V, xin, vin, ain, camerain, overspeed, l, r, k;
    bool flag;
    vector<int> x0, v0, a, cameras;
    vector<double>  x1;
    cin>>T;
    for(int i = 0; i < T; i++){
        overspeed = 0;
        x0.clear();
        v0.clear();
        a.clear();
        x1.clear();
        cameras.clear();
        cin>>n>>m>>L>>V;
        l = 0; r = m;
        for(int j = 0; j < n; j++){
            cin>>xin>>vin>>ain;
            x0.push_back(xin);
            v0.push_back(vin);
            a.push_back(ain);
            if(ain > 0){
                x1.push_back(xin + (V * V - vin * vin) / (2.0 * ain));
            }
            else if(ain == 0){
                if(vin <= V) x1.push_back(L + 1);
                else x1.push_back(0);
            }
            else if(ain < 0){
                if(vin <= V) x1.push_back(L + 1);
                else x1.push_back(xin + (V * V - vin * vin) / (2.0 * ain));
            }
        }
        for(int j = 0; j < m; j++){
            cin>>camerain;
            cameras.push_back(camerain);
        }
        for(int j = 0; j < n; j++){
            if(a[j] < 0){
                if(x1[j] > cameras[0]){
                    flag = false;
                    for(k = 0; cameras[k] < x1[j]; k++){
                        if(cameras[k] > x0[j]) overspeed++;
                    }
                    if(r < k + 1) r = k + 1;
                }
            }
            if(a[j] == 0 && x1[j] == 0) overspeed++;
            if(a[j] > 0){
                if(x1[j] < cameras[m - 1]){
                    overspeed++;
                    for(k = m - 2; k >= 0; k--){
                        if(x1[j] < cameras[k]){
                            if(l < k - 1) l = k - 1;
                            break;
                        }
                    }
                }
            }
        }
        cout<<overspeed<<" "<<r - l<<endl;
    }
    return 0;
}
